#include "../include/map.h"
#include "../base/player.h"
#include "../base/place_base.h"
#include "../include/observer.h"
#include "gtest/gtest.h"

namespace {

    class MapTest : public testing::Test {
    protected:
        void SetUp() override {
            myMap.InitAllPlaces();
        }

        void TearDown() override {

        }

        monopoly::Map myMap;
        monopoly::Observer myObserver;
        const std::string choice = "123";
    };

    TEST_F(MapTest, test_position) {
        for (int i = 0; i < 70; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getPosition(), i);
        }
    }

    TEST_F(MapTest, test_type) {
        ASSERT_EQ(myMap.PlacePtrVector[0]->getType(), monopoly::START);
        for (int i = 1; i < 14; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getType(), monopoly::ZONE);
        }
        ASSERT_EQ(myMap.PlacePtrVector[14]->getType(), monopoly::HOSPITAL);
        for (int i = 15; i < 28; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getType(), monopoly::ZONE);
        }
        ASSERT_EQ(myMap.PlacePtrVector[28]->getType(), monopoly::TOOLROOM);
        for (int i = 29; i < 35; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getType(), monopoly::ZONE);
        }
        ASSERT_EQ(myMap.PlacePtrVector[35]->getType(), monopoly::GIFTROOM);
        for (int i = 36; i < 49; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getType(), monopoly::ZONE);
        }
        ASSERT_EQ(myMap.PlacePtrVector[49]->getType(), monopoly::PRISON);
        for (int i = 50; i < 63; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getType(), monopoly::ZONE);
        }
        ASSERT_EQ(myMap.PlacePtrVector[63]->getType(), monopoly::MAGICROOM);
        for (int i = 64; i < 70; i++) {
            ASSERT_EQ(myMap.PlacePtrVector[i]->getType(), monopoly::MINE);
        }
    }

    TEST_F(MapTest, test_find_if) {
        for (int i = 0; i < 70; i++) {
            auto iter = myMap.FindPlace(i);
            ASSERT_EQ((*iter)->getPosition(), i);
        }
    }

    TEST_F(MapTest, test_player_advance) {
        monopoly::Player player;
        
        player.Advance(myMap);
        ASSERT_EQ(player.CurPlace()->getPosition(), 1);
    }



}